package mapReduce.demo05_shuffle.demo05_gradeCount;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class GroupByGradeGroupingComparator extends WritableComparator {

    public GroupByGradeGroupingComparator() {
        super(Text.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {

        Text aBean = (Text) a;
        Text bBean = (Text) b;

        String aStr = aBean.toString();
        String bStr = bBean.toString();

        String aClass = aStr.substring(0,1);
        String bClass = bStr.substring(0,1);

        return aClass.compareTo(bClass);

    }
}
